a=int(input())
for i in range(a):
    b=input()
    c=len(b)
    for d in range(c):
        e=b[d]
        if 65<=ord(e)<=90:
            print(e,end='')
    print('')
